var asset_id;

Ext.define('NIM.view.AssetDataMaster.AssetNonSacGrid', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.AssetNonSacGrid',
    id: 'assetNonSacGrid',
    items: [      
        {
        	xtype: 'grid',
		    id: 'assetNonSacGrid1',
            width: 800,
            height: 250,
            scroll : 'both',
            titleAlign: 'center',
            border: true,
            columnLines: true,
            selType: 'checkboxmodel',
            title: 'Asset Non SAC List',
		    store: 'AssetDataMaster.AssetNonSac',
		    margin: '0 0 0 0',
		    columns: [
		        {dataIndex: 'SERIAL_NUMBER', text: 'SERIAL NUMBER', align: 'left'},
		        {dataIndex: 'BARCODE', text: 'BARCODE', align: 'left'},
		        {dataIndex: 'CATEGORY', text: 'CATEGORY', align: 'left'},
		        {dataIndex: 'SUB_CATEGORY', text: 'SUB CATEGORY', align: 'left'},
		        {dataIndex: 'BRAND', text: 'BRAND', align: 'left'},
		        {dataIndex: 'TYPE', text: 'TYPE', align: 'left'},
		        {dataIndex: 'CAPACITY_UNIT', text: 'CAPCITY UNIT', align: 'left'},
		        {dataIndex: 'CAPACITY_QTY', text: 'CAPACITY QTY', align: 'left'},
		        {dataIndex: 'ITEM_UNIT', text: 'ITEM UNIT', align: 'left'},
		        {dataIndex: 'ITEM_QTY', text: 'ITEM QTY', align: 'left'},
		        {dataIndex: 'SKU_NUMBER', text: 'SKU NUMBER', align: 'left'},
		        {dataIndex: 'PART_NUMBER', text: 'PART NUMBER', align: 'left'},
		        {dataIndex: 'STATUS', text: 'STATUS', align: 'left'},
		        {dataIndex: 'REFERENCE', text: 'REFERENCE', align: 'left'},
		        {dataIndex: 'PO_NUMBER', text: 'PO NUMBER', align: 'left'},
		        {dataIndex: 'RCV_NUMBER', text: 'RCV NUMBER', align: 'left'},
		        {dataIndex: 'BAST', text: 'BAST', align: 'left'},
		    ],
		    dockedItems: [
		        {
		            xtype: 'toolbar',
		            dock: 'top',
		            items: [
		                {
		                    xtype: 'textfield',
		                    fieldLabel: 'KEYWORD',
		                    id: 'keywordAssetNonSac',
		                    margin: '0 0 0 10',
		                },
		                {
		                    xtype: 'button',
		                    text: 'SEARCH',
		                    id: 'searchAssetNonSac',
		                    margin: '0 30 0 0',
		                    handler: function () {
		                        searchGridNonSac();
		                    }
		                },
		                {
		                    xtype: 'button',
		                    text: 'REFRESH',
		                    id: 'refreshAssetNonSac',
		                    handler: function () {
		                        refreshGridNonSac();
		                    }
		                },
		                {
		                    xtype: 'button',
		                    text: 'ADD NEW',
		                    id: 'AddAssetNonSac',
		                    handler: function () {
		                        Ext.getCmp('assetMainForm').removeAll(true);
		                        Ext.getCmp('assetMainForm').add({xtype: 'AssetNonSacForm'});
		                        Ext.getCmp('assetMainForm').doLayout();
		                    }
		                },
		                {
		                    xtype: 'button',
		                    text: 'EXPORT TO PDF',
		                    icon : 'images/pdf-icon-btn.png',
		                    handler: function () {
	                			location.href = pdf+""+site_id;
		                    }
		                },
		                {
		                    xtype: 'button',
		                    text: 'EXPORT TO EXCEL',
		                    icon : 'images/Excel-icon-btn.png',
		                    handler: function () {
		                		location.href = xls+""+site_id;
		                    }
		                }
		            ]
		        }
		    ],
		    listeners: {
		        itemdblclick: function (grid, record) {
		            asset_id = record.get('ASSET_DETAIL_ID');
		            Ext.getCmp('assetMainForm').removeAll(true);
		            Ext.getCmp('assetMainForm').add({xtype: 'AssetNonSacForm'});
		            Ext.getCmp('assetMainForm').doLayout();
		
		            setDataNonSac();
		        },
		        
	        	itemclick: function (grid, record) {
	        		asset_id = record.get('ASSET_DETAIL_ID');
	        		filterNonSacLogs( asset_id,category);
	        	},
	        	
		        afterrender: function () {
		            filterGridNonSac(site_id, category);
		            Ext.getCmp('assetNonSacGrid1').setTitle(category);
		        }
	        }
        },
        {
        	xtype: 'grid',
		    id: 'assetNonSacGrid2',
            width: 800,
            height: 200,
            scroll : 'both',
            titleAlign: 'center',
            border: true,
            columnLines: true,
            selType: 'checkboxmodel',
            title: 'Asset Non SAC Logs List',
		    store: 'AssetDataMaster.AssetNonSacLogs',
		    margin: '20 0 0 0',
		    columns: [
		        {dataIndex: 'SERIAL_NUMBER', text: 'SERIAL NUMBER', align: 'left'},
		        {dataIndex: 'BARCODE', text: 'BARCODE', align: 'left'},
		        {dataIndex: 'CATEGORY', text: 'CATEGORY', align: 'left'},
		        {dataIndex: 'SUB_CATEGORY', text: 'SUB CATEGORY', align: 'left'},
		        {dataIndex: 'BRAND', text: 'BRAND', align: 'left'},
		        {dataIndex: 'TYPE', text: 'TYPE', align: 'left'},
		        {dataIndex: 'CAPACITY_UNIT', text: 'CAPCITY UNIT', align: 'left'},
		        {dataIndex: 'CAPACITY_QTY', text: 'CAPACITY QTY', align: 'left'},
		        {dataIndex: 'ITEM_UNIT', text: 'ITEM UNIT', align: 'left'},
		        {dataIndex: 'ITEM_QTY', text: 'ITEM QTY', align: 'left'},
		        {dataIndex: 'SKU_NUMBER', text: 'SKU NUMBER', align: 'left'},
		        {dataIndex: 'PART_NUMBER', text: 'PART NUMBER', align: 'left'},
		        {dataIndex: 'STATUS', text: 'STATUS', align: 'left'},
		        {dataIndex: 'REFERENCE', text: 'REFERENCE', align: 'left'},
		        {dataIndex: 'PO_NUMBER', text: 'PO NUMBER', align: 'left'},
		        {dataIndex: 'RCV_NUMBER', text: 'RCV NUMBER', align: 'left'},
		        {dataIndex: 'BAST', text: 'BAST', align: 'left'},
		    ],
	        listeners: {
		        afterrender: function () {
		            filterGridNonSacLogs(site_id, category);
		            Ext.getCmp('assetNonSacGrid2').setTitle(category+' LOGS');
		        },
		        
	        }
        }   
    ]           
});
                


